<template>
	<view>
		<view class="grid-box">
			<view><text class="tips-txt"><u-icon name="rmb-circle" size="28"></u-icon>我的账户总额(元)</text></view>
			<view class="u-p-t-10"><text class="u-font-56 main-txt bold-txt">{{utils.formatMoney(userdetail.balancetotal)}}</text></view>
			<view class="label-box u-m-t-30">
				<view class="item">
					<view><text class="tips-txt">个人账户(元)</text></view>
					<view class="u-p-t-6"><text class="u-font-36">{{utils.formatMoney(userdetail.balance)}}</text></view>
				</view>
				<view class="item">
					<view><text class="tips-txt">其他账户(元)</text></view>
					<view class="u-p-t-6"><text class="u-font-36">{{utils.formatMoney(userdetail.enterprisebalance)}}</text></view>
				</view>
			</view>
			<view class="u-p-t-30">
				<u-button type="primary" @click="all">全部提现</u-button>
			</view>
		</view>
		<view class="grid-box u-p-0" style="overflow: hidden;">
			<view class="head-title u-p-30"><text class="u-font-32">选择账户提现</text></view>
			<!-- <view class="u-p-30">
				<u-alert-tips type="warning" title="温馨提示：" description="您有多个有余额的账户，请选择账户提现"></u-alert-tips>
			</view> -->
			<u-cell-group>
				<u-cell-item title="个人账户" @click="cashOut(0,userdetail.id)">
					<text class="main-txt">余额：{{utils.formatMoney(userdetail.balance)}}元</text>
				</u-cell-item>
				<u-cell-item 
					v-for="(item,index) in ortherAccount"
					:key="index"
					:title="item.name" 
					:label="item.type"
					@click="cashOut(1,item.id)">
					<text class="main-txt">余额：{{utils.formatMoney(item.balance)}}元</text>
				</u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	
	export default {
		data() {
			return {
				ortherAccount: []
			}
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail,
				webSetting: state => state.webSetting
			})
		},
		onLoad() {
			this.$store.dispatch('getDetails').then((res)=>{
				this.ortherAccount = res?.bindinfo?.enterpriselist
				console.log('ortherAccount',this.ortherAccount)
			}).finally(()=>{
				// this.loading = false
				uni.hideLoading()
			})
		},
		methods: {
			// 选择提现
			cashOut(type,id){ //type: 0个人，1客户组
				if(type == 0){
					uni.navigateTo({
						url: '/pages/my/wallet/cashOut/cashOut?userid='+id
					})
				}else{
					uni.navigateTo({
						url: '/pages/my/wallet/cashOut/cashOut?enterpriseid='+id
					})
				}
			},
			all(){
				uni.navigateTo({
					url: '/pages/my/wallet/cashOut/cashOut?all=1'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main-txt{
		color: $u-color-orange;
	}
	.label-box {
		display: flex;
		background-color: $u-color-light;
		padding: 20rpx;
		border-radius: 12rpx;
		// box-shadow: 0px -36rpx 0 #34ac9ad9;

		.item {
			flex: 1;
			// text-align: center;
			// border-right: 1px solid $u-border-color;
			color: $u-content-color;

			&:last-child {
				border-right: 0;
			}

			.num {
				color: $u-color-red;
				font-weight: bold;
			}
		}
	}
</style>
